package control;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import bean.Flight;
import bean.Panel;


@Controller
public class PanelControl {

	@Resource
	Dao dao;
	
	@RequestMapping(value="/addPanel",method=RequestMethod.POST)
	public @ResponseBody Panel addPanel(String name, String hourOfDisplay, Integer idxFlight)
	{
		System.out.println("addPanel");		
		return dao.addPanel(name, Utils.getHourFromString(hourOfDisplay), idxFlight);
	}

	@RequestMapping(value="/removePanel",method=RequestMethod.GET)
	public @ResponseBody boolean removePanel(int idPanel)
	{
		System.out.println("removePanel");		
		return dao.removePanel(idPanel);
	}

	@RequestMapping(value="/modifiyPanel",method=RequestMethod.GET)		
	public @ResponseBody boolean modifiyPanel(int idxPanel, String name, String hourOfDisplay, Integer idxFlight)
	{
		System.out.println("modifiyPanel");		
		return dao.modifiyPanel(idxPanel, name,  Utils.getHourFromString(hourOfDisplay), idxFlight)	;	
	}
		
	@RequestMapping(value="/getPanel",method=RequestMethod.GET)
	public @ResponseBody Panel getPanel( int idxPanel)
	{
		System.out.println("getPanel");		
		return dao.getPanel(idxPanel);	
	}
			
	@RequestMapping(value="/getPanels",method=RequestMethod.GET)		
	public @ResponseBody List<Panel> getPanels()
	{
		System.out.println("getPanels");		
		return dao.getPanels();
	}
	
	@RequestMapping(value="/getPanelToDisplay",method=RequestMethod.GET)
	public @ResponseBody Panel getFlightToDisplay(){
		System.out.println("getPanelToDisplay");
		return dao.getPanelToDisplay();
	}
}
